package com.example.s08restful_sagger.pojo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @auther Qiang
 * @date 2022/4/4 9:21
 */

@ApiModel(description = "响应对象")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class BaseResult<T>
{
    private static final int SUCCESS_CODE = 0;
    private static final String SUCCESS_MESSAGE = "成功";

    @ApiModelProperty(value = "响应码", name = "code", required = true, example = "" + SUCCESS_CODE)
    private int code;
    @ApiModelProperty(value = "响应消息", name = "msg", required = true, example = SUCCESS_MESSAGE)
    private String msg;
    @ApiModelProperty(value = "响应数据", name = "data")
    private T data;

    public static BaseResult success(Object o)
    {
        return new BaseResult(SUCCESS_CODE,SUCCESS_MESSAGE,o);
    }
}